<?php
namespace frontend\models;

use common\models\Active;
use yii\base\Model;
use Yii;

/**
 * 活动商品 逻辑层
 */
class ActiveGoodForm extends Model
{

    /**
     * 获取有效抢购活动 商品列表
     */
    public function getValidActiveGoodList()
    {
        /*

        ->from( [ 'a' => Active::tableName() ] )
            ->select( $field2select )

         */

        $field2select = [
            'a.id','a.title','a.time_begin','a.time_end','a.sys_status',
        ];

        return Active::find()
            ->from( [ 'a' => Active::tableName() ] )
            ->with( 'goods' )
            ->where( [ 'a.sys_status' => 1 ] )
            ->asArray()
            ->all();
    }

}
